package com.zhongfl.crm.api.view;

import com.zhongfl.crm.enums.boss.AmibaCode;
import com.zhongfl.crm.model.boss.Amiba;
import com.zhongfl.crm.model.boss.AmibaStaff;
import com.zhongfl.crm.service.boss.AmibaService;
import com.zhongfl.crm.service.boss.AmibaStaffService;
import org.springframework.web.bind.annotation.*;
import tech.heptagram.core.common.rest.ResponseResult;
import tech.heptagram.staff.model.Staff;
import tech.heptagram.staff.query.StaffQuery;
import tech.heptagram.staff.service.StaffService;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 木叶丸
 * @date 2019/3/14 16:55
 */
@RestController
@RequestMapping("/api/view/amiba")
public class AmibaApiController {

    @Resource
    private AmibaStaffService amibaStaffService;

    @Resource
    private AmibaService amibaService;


    @Resource
    private StaffService staffService;

    @GetMapping("/list/staffCode/{staffCode}")
    ResponseResult<List<AmibaStaff>> findByStaffCode(@PathVariable String staffCode) {
        List<AmibaStaff> list = amibaStaffService.findByStaffCodeAndAmibaCode(staffCode, AmibaCode.XIAO_SHOU);
        return new ResponseResult<>(list);
    }

    @GetMapping("/list/all")
    ResponseResult<List<Amiba>> findAll() {
        List<Amiba> list = amibaService.findAll();
        return new ResponseResult<>(list);
    }


    @GetMapping("/staff/list")
    ResponseResult staffs(@RequestParam String staffMobile) {
        StaffQuery staffQuery = new StaffQuery();
        staffQuery.setMobile(staffMobile);
        Staff staff = staffService.getStaff(staffQuery);
        return new ResponseResult<>(staff);
    }

    @GetMapping("/list/{code}")
    ResponseResult<List<Amiba>> findByCode(@PathVariable String code) {
        List<Amiba> lists = amibaService.findByCode(code);
        return new ResponseResult<>(lists);
    }
}
